<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="com.fick.hibernate.model.*"%>
<%@ page import="com.fick.hibernate.dao.*"%>
<%@page import="com.fick.tools.SystemLogger"%>
<%@ include file="../tld/tlds.jsp"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<style type="text/css">
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
}
.STYLE1 {font-size: 12px;}
.STYLE4 {
	font-size: 12px;
	color: #1F4A65;
	font-weight: bold;
}

a:link {
	font-size: 12px;
	color: #06482a;
	text-decoration: none;

}
a:visited {
	font-size: 12px;
	color: #06482a;
	text-decoration: none;
}
a:hover {
	font-size: 12px;
	color: #FF0000;
	text-decoration: underline;
}
a:active {
	font-size: 12px;
	color: #FF0000;
	text-decoration: none;
}
.STYLE7 {font-size: 12px;}

</style>
<script type="text/javascript" src="js/meihuaxue.js"></script>
		<script type="text/javascript" src="js/prototype.js"></script>
		<script type="text/javascript" src="js/submit.js"></script>
</head>
<%   NewsDAO newdao=new NewsDAO();
    AdminQxDAO qxdao=new AdminQxDAO();
Admin admin=(Admin)request.getSession().getAttribute("admin");		   
int pagesize=20;
int currpage=1;
//总的页数
int totalPage = 1;
//总共有的记录数
int totalCount = 1;
List newslist=null;
if(admin.getRole().getId() == 3 || admin.getRole().getId() == 5){
	totalCount=newdao.count(News.class,"where isAss='2'");
}
else
{
	totalCount=newdao.count(News.class,"where admin.adminId='"+admin.getAdminId()+"' and isAss='2'");
}
//得到总的页数
if(totalCount%pagesize==0){
	totalPage = totalCount/pagesize;
}else{
	totalPage = totalCount/pagesize+1;
}
//判断是否是传过来页数
if(request.getParameter("currpage") != null){
   currpage = Integer.parseInt(request.getParameter("currpage"));
   if(currpage<1){
     currpage=1;
    }
   if(currpage >totalPage){
     currpage = totalPage;
   }
} 
if(admin.getRole().getId() == 3 || admin.getRole().getId() == 5){
			newslist=newdao.findPageByHql("where isAss='2' order by addDate desc",currpage,pagesize);
    }
else
    {
			newslist=newdao.findPageByHql("where admin.adminId='"+admin.getAdminId()+"' and isAss='2' order by addDate desc",currpage,pagesize);
	}
%>
<body>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="30">
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="15" height="30"><img src="images/tab_03.gif" width="15" height="30" /></td>
        <td width="1101" background="images/tab_05.gif"><img src="images/311.gif" width="16" height="16" />
			<span class="STYLE4">信息回收站页面</span></td>
        <td width="281" background="images/tab_05.gif">
        &nbsp;
        </td>
        <td width="14"><img src="images/tab_07.gif" width="14" height="30" /></td>
      </tr>
    </table>
    </td>
  </tr>
  <tr>
    <td>
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="9" background="images/tab_12.gif">&nbsp;</td>
        <td bgcolor="#f3ffe3">
        <table width="98%" border="0" cellpadding="0" cellspacing="1" bgcolor="#D7DFE1">
        <tr>
        <td width="32%" height="25" background="images/tab_14.gif" class="STYLE1"><div align="center" class="STYLE1">标题</div></td>
        <td width="16%" height="25" background="images/tab_14.gif" class="STYLE1"><div align="center" class="STYLE1">所属栏目</div></td>
        <td width="20%" height="25" background="images/tab_14.gif" class="STYLE1"><div align="center" class="STYLE1">发布时间</div></td>
        <td width="10%" height="25" background="images/tab_14.gif" class="STYLE1"><div align="center" class="STYLE1">作者</div></td>
        <td width="7%" height="25" background="images/tab_14.gif" class="STYLE1"><div align="center" class="STYLE1">状态</div></td>
        <td width="15%" height="25" background="images/tab_14.gif" class="STYLE1"><div align="center" class="STYLE1">还原</div></td>
        </tr>
        <%
			for(int i = 0 ; i < newslist.size(); i++){
				News news = (News)newslist.get(i);
		%>
		<tr>
        
          <td width="35%" height="25" align="left" valign="middle" bgcolor="#FFFFFF" style="padding-left:7px" class="STYLE1">
		  <%
	
			if(news.getTitle().length()>40){										        	
			   out.print(news.getTitle().substring(0,40)+"..");
			 }else{
				out.print(news.getTitle());
			 }
		   %>
		  
		  </td>
		  <td width="10%" height="25" align="center" valign="middle" bgcolor="#FFFFFF" class="STYLE1"><%=news.getChannelid().getName() %></td>
          <td width="10%" height="25" align="center" valign="middle" bgcolor="#FFFFFF" class="STYLE1"><%=news.getAddDate().toString().substring(0,10) %></td>
          <%Admin admin2=news.getAdmin(); 
          %>
          <td width="8%" height="25" align="center" valign="middle" bgcolor="#FFFFFF" class="STYLE1"><%=admin2.getAdminName()%></td>
          <td width="10%" height="25" align="center" valign="middle" bgcolor="#FFFFFF" class="STYLE1"><%="1".equals(news.getIsAss()) ? "已审核" : "未审核" %></td>
          <td width="15%" height="25" align="center" valign="middle" bgcolor="#FFFFFF" class="STYLE1">
		  <a href="<%=request.getContextPath()%>/admin/managerNew.do?pagesrc=recycle&method=assByIds&newsid=<%=news.getNewId() %>">还原</a>&nbsp;
			<a href="<%=request.getContextPath()%>/admin/managerNew.do?pagesrc=recycle&method=delById&newsid=<%=news.getNewId() %>" onclick="return confirm('确定要删除吗')">彻底删除</a>
		  </td>
        </tr>
		<%
			}
		%>
      </table>
        </td>
        <td width="9" background="images/tab_16.gif">&nbsp;</td>
      </tr>
    </table>
    </td>
  </tr>
  <tr>
    <td height="29">
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="15" height="29"><img src="images/tab_20.gif" width="15" height="29" /></td>
        <td background="images/tab_21.gif">
              <table width="98%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td height="25" align="center" valign="middle" class="STYLE1">
		  共有［<%=totalCount %>］条 当前是第［<%=currpage %>/<%=totalPage %>］页 [<a href="recycle_list.jsp?currPage=1" class="page">首页</a>] [<a href="recycle_list.jsp?currPage=<%=currpage-1 %>" class="page">上一页</a>] [<a href="recycle_list.jsp?currPage=<%=currpage+1 %>" class="page">下一页</a>] [<a href="recycle_list.jsp?currPage=<%=totalPage %>" class="page">尾页</a>]
		  到第
            <select name="select" onChange="gopage(this)">
			<%
				for(int i = 0;i<totalPage ; i++)
				{
					out.print("<option value='recycle_list.jsp?currPage="+(i+1)+"'>"+(i+1)+"</option>");
				}
			%>
			
            </select>
          页
		 </td>
        </tr>
      </table>
        </td>
        <td width="14"><img src="images/tab_22.gif" width="14" height="29" /></td>
      </tr>
    </table></td>
  </tr>
</table>
</body>
</html>
<script type="text/javascript">
var message = "<%=session.getAttribute("message")%>";
if(message!=null && message!="null" && message !=""){
   alert(message);
   message="";
  }
</script>
<%
	session.removeAttribute("message");
%>